/*     */ package com.qmsk.business.bussBill.depositTotal.dao;
/*     */ 
/*     */ import com.qmsk.business.sys.basic.SupportDAO;
/*     */ import com.utils.basic.CDateTimeComm;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.basic.ObjectComm;
/*     */ import com.utils.gson.in.GsonHeadManyRows;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.gson.out.GsonEbUtils;
/*     */ import java.sql.SQLException;
/*     */ import java.util.Date;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.lang.StringUtils;
/*     */ 
/*     */ public class DepositTotalDao extends SupportDAO
/*     */ {
/*     */   public GsonHeadManyRows getGsonOfShopIdMember(Map<String, Object> params, Integer nPageIdx, Short nPageSize)
/*     */     throws SQLException
/*     */   {
/*  22 */     return getManyRowsOfParams("selectSqlTotalMember", 
/*  23 */       "selectJsonTotalMember", params, nPageIdx, nPageSize);
/*     */   }
/*     */ 
/*     */   public GsonEbRst getGson(Map<String, Object> params, Integer nPageIdx, Short nPageSize) throws SQLException
/*     */   {
/*  28 */     GsonHeadManyRows ss = getGsonOfShopIdMember(params, nPageIdx, nPageSize);
/*  29 */     if ((ss != null) && (ss.getDataLength() > 0)) {
/*  30 */       long nTotals = queryCustCount(params);
/*  31 */       int nHeadOld = ss.getHead().length;
/*  32 */       Date begin = (Date)params.get("dtPaidStart");
/*  33 */       Date dateEnd = (Date)params.get("dtPaidEnd");
/*  34 */       int nDays = (int)CDateTimeComm.getDiffDay(dateEnd, 
/*  35 */         begin);
/*  36 */       String[] heads = null;
/*  37 */       Object[] datas = null;
/*     */ 
/*  39 */       heads = new String[nDays * 2];
/*  40 */       datas = new Object[nDays * 2];
/*     */ 
/*  42 */       int i = 0; for (int j = 0; i < heads.length; i += 2) {
/*  43 */         Date dtPer = CDateTimeComm.getAddDate(begin, j);
/*  44 */         heads[i] = CDateTimeComm.dateToyyyymmdd(dtPer) + "|预存";
/*  45 */         heads[(i + 1)] = CDateTimeComm.dateToyyyymmdd(dtPer) + "|支出";
/*  46 */         datas[i] = Integer.valueOf(0);
/*  47 */         datas[(i + 1)] = Integer.valueOf(0);
/*  48 */         ++j;
/*     */       }
/*  50 */       ss.addHeadData(heads, datas);
/*     */ 
/*  52 */       String[] heads1 = { "合计预存", "合计支出" };
/*  53 */       Object[] datas1 = { Integer.valueOf(0), Integer.valueOf(0) };
/*  54 */       ss.autoAddHeadData(heads1, datas1);
/*  55 */       int n = 0; 
/*     */       while (true) { Integer custId = ObjectComm.objectToInteger(
/*  57 */           ss.getValueOfName("custId", n), Integer.valueOf(0));
/*  58 */         if (custId != null) if (custId.intValue() > 0)
/*     */           {
/*  61 */             GsonHeadManyRows manySumPlus = getSum(params, custId);
/*  62 */             GsonHeadManyRows manySumMinus = getSumMinus(params, custId);
/*  63 */             Double jia = Double.valueOf(0.0D);
/*  64 */             Double jian = Double.valueOf(0.0D);
/*  65 */             for (int j = nHeadOld; j < ss.getHead().length - 2; ++j) {
/*  66 */               String sDayPer = ss.getHeadValueOfIdx(j);
/*  67 */               int nPos = sDayPer.lastIndexOf(124);
/*  68 */               if (nPos > 0) {
/*  69 */                 String sOper = StringUtils.substring(sDayPer, nPos + 1, 
/*  70 */                   sDayPer.length());
/*  71 */                 String dayPer = StringUtils.substring(sDayPer, 0, nPos);
/*     */ 
/*  73 */                 Double shu = Double.valueOf(0.0D);
/*     */                 int k;
/*     */                 Date adate;
/*     */                 String sDate;
/*     */                 Double dpsit;
/*  74 */                 if ((sOper.equalsIgnoreCase("预存")) && 
/*  75 */                   (manySumPlus != null) && 
/*  76 */                   (manySumPlus.getDataLength() > 0)) {
/*  77 */                   for (k = 0; k < manySumPlus.getDataLength(); ++k) {
/*  78 */                     adate = (Date)manySumPlus
/*  79 */                       .getValueOfName("ReceDate", k);
/*  80 */                     sDate = 
/*  81 */                       CDateTimeComm.dateToyyyymmdd(adate);
/*  82 */                     if (dayPer.equals(sDate)) {
/*  83 */                       dpsit = 
/*  84 */                         ObjectComm.objectToDouble(manySumPlus
/*  85 */                         .getValueOfName(
/*  86 */                         "BillAmt", k), 
/*  87 */                         Double.valueOf(0.0D));
/*  88 */                       shu = dpsit;
/*  89 */                       jia = Double.valueOf(jia.doubleValue() + dpsit.doubleValue());
/*     */                     }
/*     */                   }
/*     */                 }
/*     */ 
/*  94 */                 if ((sOper.equalsIgnoreCase("支出")) && 
/*  95 */                   (manySumMinus != null) && 
/*  96 */                   (manySumMinus.getDataLength() > 0)) {
/*  97 */                   for (k = 0; k < manySumMinus.getDataLength(); ++k) {
/*  98 */                     adate = (Date)manySumMinus
/*  99 */                       .getValueOfName("ReceDate", k);
/* 100 */                     sDate = 
/* 101 */                       CDateTimeComm.dateToyyyymmdd(adate);
/* 102 */                     if (dayPer.equals(sDate)) {
/* 103 */                       dpsit = 
/* 104 */                         ObjectComm.objectToDouble(manySumMinus
/* 105 */                         .getValueOfName(
/* 106 */                         "PayDepstAmt", 
/* 107 */                         k), Double.valueOf(0.0D));
/* 108 */                       shu = dpsit;
/* 109 */                       jian = Double.valueOf(jian.doubleValue() + dpsit.doubleValue());
/*     */                     }
/*     */                   }
/*     */ 
/*     */                 }
/*     */ 
/* 115 */                 ss.setValueOfIdx(n, j, shu);
/*     */               }
/*     */             }
/* 118 */             ss.setValueOfIdx(n, ss.getHead().length - 2, jia);
/* 119 */             ss.setValueOfIdx(n, ss.getHead().length - 1, jian);
/*     */           }
/*  55 */         ++n; if (n >= ss.getDataLength())
/*     */         {
/* 121 */           label679: return GsonEbUtils.toGsonEbRst(ss, nTotals); } }
/*     */     }
/* 123 */     return GsonEbUtils.toGsonEbRst(ss);
/*     */   }
/*     */ 
/*     */   private long queryCustCount(Map<String, Object> params)
/*     */     throws SQLException
/*     */   {
/* 129 */     return queryForLong("selectCountTotalMember", params, Long.valueOf(0L)).longValue();
/*     */   }
/*     */ 
/*     */   private GsonHeadManyRows getSumMinus(Map<String, Object> params, Object custId) throws SQLException
/*     */   {
/* 134 */     MapUtils.addToMap(params, "custId", custId);
/* 135 */     return getManyRowsOfParams("selectSqlSum", "selectJsonSum", params);
/*     */   }
/*     */ 
/*     */   public GsonHeadManyRows getSum(Map<String, Object> params, Object custId) throws SQLException
/*     */   {
/* 140 */     MapUtils.addToMap(params, "custId", custId);
/* 141 */     return getManyRowsOfParams("selectSqlSumOfStID", "selectJsonSumOfStID", 
/* 142 */       params);
/*     */   }
/*     */ 
/*     */   public GsonEbRst getGsonOfSum(Map<String, Object> params) throws SQLException
/*     */   {
/* 147 */     GsonHeadOneRow g = getGsonOfShopIdMember(params);
/* 148 */     if ((g != null) && (g.getDataLength() > 0)) {
/* 149 */       int nHeadOld = g.getHead().length;
/* 150 */       Date begin = (Date)params.get("dtPaidStart");
/* 151 */       Date dateEnd = (Date)params.get("dtPaidEnd");
/* 152 */       int nDays = (int)CDateTimeComm.getDiffDay(dateEnd, 
/* 153 */         begin);
/* 154 */       String[] heads = null;
/* 155 */       Object[] datas = null;
/*     */ 
/* 157 */       heads = new String[nDays * 2];
/* 158 */       datas = new Object[nDays * 2];
/*     */ 
/* 160 */       int i = 0; for (int j = 0; i < heads.length; i += 2) {
/* 161 */         Date dtPer = CDateTimeComm.getAddDate(begin, j);
/* 162 */         heads[i] = CDateTimeComm.dateToyyyymmdd(dtPer) + "|预存";
/* 163 */         heads[(i + 1)] = CDateTimeComm.dateToyyyymmdd(dtPer) + "|支出";
/* 164 */         datas[i] = Integer.valueOf(0);
/* 165 */         datas[(i + 1)] = Integer.valueOf(0);
/* 166 */         ++j;
/*     */       }
/* 168 */       g.addHeadData(heads, datas);
/* 169 */       String[] heads1 = { "合计预存", "合计支出" };
/* 170 */       Object[] datas1 = { Integer.valueOf(0), Integer.valueOf(0) };
/* 171 */       g.addHeadData(heads1, datas1);
/* 172 */       Double jia = Double.valueOf(0.0D);
/* 173 */       Double jian = Double.valueOf(0.0D);
/* 174 */       for (int j = nHeadOld; j < g.getHead().length - 2; ++j) {
/* 175 */         String sDayPer = g.getHeadValueOfIdx(j);
/* 176 */         int nPos = sDayPer.lastIndexOf(124);
/* 177 */         if (nPos > 0) {
/* 178 */           String sOper = sDayPer
/* 179 */             .substring(nPos + 1, sDayPer.length());
/* 180 */           String dayPer = sDayPer.substring(0, nPos);
/*     */ 
/* 182 */           Double shu = Double.valueOf(0.0D);
/* 183 */           Double shu1 = Double.valueOf(0.0D);
/*     */           Date sdate;
/*     */           Double dpsit;
/* 184 */           if (sOper.equalsIgnoreCase("预存")) {
/* 185 */             sdate = CDateTimeComm.yymmddToDate(dayPer);
/* 186 */             dpsit = getSum(params, sdate);
/* 187 */             shu1 = dpsit;
/* 188 */             jia = Double.valueOf(jia.doubleValue() + dpsit.doubleValue());
/* 189 */             g.setValueOfIdx(j, shu1);
/*     */           }
/*     */ 
/* 192 */           if (sOper.equalsIgnoreCase("支出")) {
/* 193 */             sdate = CDateTimeComm.yymmddToDate(dayPer);
/* 194 */             dpsit = getSumMinus(params, sdate);
/* 195 */             shu = dpsit;
/* 196 */             jian = Double.valueOf(jian.doubleValue() + dpsit.doubleValue());
/* 197 */             g.setValueOfIdx(j, shu);
/*     */           }
/*     */         }
/*     */       }
/*     */ 
/* 202 */       g.setValueOfIdx(g.getHead().length - 2, jia);
/* 203 */       g.setValueOfIdx(g.getHead().length - 1, jian);
/* 204 */       g.autoAddHeadData("levelName", "");
/* 205 */       return GsonEbUtils.toGsonEbRst(g);
/*     */     }
/* 207 */     return GsonEbUtils.toGsonEbRst(g);
/*     */   }
/*     */ 
/*     */   private Double getSumMinus(Map<String, Object> params, Date date)
/*     */     throws SQLException
/*     */   {
/* 213 */     MapUtils.addToMap(params, "date", date);
/* 214 */     return queryForDouble("selectSqlSum_", params, Double.valueOf(0.0D));
/*     */   }
/*     */ 
/*     */   private Double getSum(Map<String, Object> params, Date date) throws SQLException
/*     */   {
/* 219 */     MapUtils.addToMap(params, "date", date);
/* 220 */     return queryForDouble("selectSqlSumOfStID_", params, Double.valueOf(0.0D));
/*     */   }
/*     */ 
/*     */   private GsonHeadOneRow getGsonOfShopIdMember(Map<String, Object> params) throws SQLException
/*     */   {
/* 225 */     return getOneRowOfParams("selectSqlDepositSum", "selectJsonDepositSum", 
/* 226 */       params);
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.bussBill.depositTotal.dao.DepositTotalDao
 * JD-Core Version:    0.5.3
 */